package com.wjy.exception.business;

import com.wjy.response.ResponseBuilder;
import lombok.extern.log4j.Log4j2;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

/**
 * @author ybxxszl
 * @date 2018年10月10日
 * @description 业务异常处理
 */
@Log4j2
@Provider
public class BusinessExceptionHandle implements ExceptionMapper<BusinessException> {

    @Override
    public Response toResponse(BusinessException exception) {

        log.info("业务异常：" + exception.getMessage());

        return ResponseBuilder.exception(exception);

    }

}
